package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zlict.admin.domain.RdPortfolioAssets;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.RdLeaseAssets;
import com.zlict.admin.service.IRdLeaseAssetsService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 资产管理-经营租赁Controller
 * 
 * @author lqh
 * @date 2025-06-13
 */
@RestController
@RequestMapping("/assets/leaseAssets")
@RequiredArgsConstructor
public class RdLeaseAssetsController extends BaseController
{
    private final IRdLeaseAssetsService rdLeaseAssetsService;

    /**
     * 查询资产管理-经营租赁列表(分页)
     */
//    @PreAuthorize("@ss.hasPermi('admin:leaseAssets:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdLeaseAssets rdLeaseAssets)
    {
        startPage();
        List<RdLeaseAssets> list = rdLeaseAssetsService.selectRdLeaseAssetsList(rdLeaseAssets);
        return getDataTable(list);
    }

    /**
     * 导出资产管理-经营租赁列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:leaseAssets:export')")
    @Log(title = "资产管理-经营租赁", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RdLeaseAssets rdLeaseAssets)
    {
        List<RdLeaseAssets> list = rdLeaseAssetsService.selectRdLeaseAssetsList(rdLeaseAssets);
        ExcelUtil<RdLeaseAssets> util = new ExcelUtil<RdLeaseAssets>(RdLeaseAssets.class);
        util.exportExcel(response, list, "资产管理-经营租赁数据");
    }

    /**
     * 获取资产管理-经营租赁详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:leaseAssets:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rdLeaseAssetsService.selectRdLeaseAssetsById(id));
    }

    /**
     * 新增资产管理-经营租赁
     */
//    @PreAuthorize("@ss.hasPermi('admin:leaseAssets:add')")
    @Log(title = "资产管理-经营租赁", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdLeaseAssets rdLeaseAssets)
    {
        return toAjax(rdLeaseAssetsService.insertRdLeaseAssets(rdLeaseAssets));
    }

    /**
     * 修改资产管理-经营租赁
     */
//    @PreAuthorize("@ss.hasPermi('admin:leaseAssets:edit')")
    @Log(title = "资产管理-经营租赁", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdLeaseAssets rdLeaseAssets)
    {
        return toAjax(rdLeaseAssetsService.updateRdLeaseAssets(rdLeaseAssets));
    }

    /**
     * 删除资产管理-经营租赁
     */
//    @PreAuthorize("@ss.hasPermi('admin:leaseAssets:remove')")
    @Log(title = "资产管理-经营租赁", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdLeaseAssetsService.deleteRdLeaseAssetsByIds(ids));
    }

    /**
     * 查询资产管理-经营租赁列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioassets:getList')")
    @GetMapping("/getList")
    public AjaxResult getList(RdLeaseAssets rdLeaseAssets)
    {
        List<RdLeaseAssets> list = rdLeaseAssetsService.selectRdLeaseAssetsList(rdLeaseAssets);
        return success(list);
    }
}
